import 'package:flutter/material.dart' ;
import 'package:flutter_screenutil/flutter_screenutil.dart';

class MyDialog extends StatefulWidget {
  String title ;
  dynamic yes ;
  dynamic no ;
  MyDialog({Key key , @required this.title , @required this.yes , @required this.no}):super(key:key) ;
  @override
  _MyDialogState createState() => _MyDialogState();
}

class _MyDialogState extends State<MyDialog> {
  @override
  Widget build(BuildContext context) {
    return AlertDialog(
      backgroundColor: Color.fromARGB(0, 0, 0, 0),
      contentPadding: EdgeInsets.all(0),
      titlePadding: EdgeInsets.all(0) ,
      content: Container(
        padding: EdgeInsets.all(0) ,
        width: ScreenUtil().setWidth(280),
        height: ScreenUtil().setWidth(133),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.all(Radius.circular(8)) ,
          color: Colors.white 
        ),
        child: Column(
          children: <Widget>[
            Container(
              height: ScreenUtil().setWidth(83),
              width: ScreenUtil().setWidth(280),
              child: Center(
                child: Text(widget.title.toString() , style: TextStyle(
                  fontSize: ScreenUtil().setSp(16) ,
                  fontWeight: FontWeight.bold ,
                  color: Color.fromARGB(255, 19, 27, 54)
                ),),
              ),
            ) ,
            Container(
              height: ScreenUtil().setWidth(1),
              color: Color.fromARGB(255, 221, 221, 221),
            ) ,
            Container(
              height: ScreenUtil().setWidth(49),
              child: Row(
                children: <Widget>[
                  GestureDetector(
                    child: Container(
                      color: Color.fromARGB(0, 0, 0, 0),
                      width: ScreenUtil().setWidth(140),
                      child: Center(
                        child: Text("取消" , style: TextStyle(
                          fontSize: ScreenUtil().setSp(18) ,
                          color: Color.fromARGB(255, 19, 28, 54) ,
                        ),),
                      ),
                    ) ,
                    onTap: (){
                      try{
                        widget.no() ;
                      }catch(e){}
                      Navigator.of(context).pop() ;
                    },
                  ),
                  Container(
                    width: ScreenUtil().setWidth(1),
                    color: Color.fromARGB(255, 221, 221, 221),
                  ) ,
                  GestureDetector(
                    child: Container(
                      color: Color.fromARGB(0, 0, 0, 0),
                      width: ScreenUtil().setWidth(139),
                      child: Center(
                        child: Text("确认" , style: TextStyle(
                          fontSize: ScreenUtil().setSp(18) ,
                          fontWeight: FontWeight.bold ,
                          color: Color.fromARGB(255, 0, 195, 206) ,
                        ),),
                      ),
                    ),
                    onTap: (){
                      widget.yes() ;
                    },
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}